import type { InventoryHistoryRecord } from '@/DatabaseType/InventoryHistory';
import type { PaginationConfig } from '@/types';
import { ServiceProxy } from '@/constant';
import type { RequestResult } from '@/utils/request';
import { request } from '@umijs/max';

// 获取角色列表
export async function getInventoryHistoryList(
  params: Pick<InventoryHistoryRecord, 'id' | 'brandId' | 'type'> &
    PaginationConfig & {
      createStartTime?: number;
      createEndTime?: number;
    },
): Promise<
  RequestResult<{
    total: number;
    list: InventoryHistoryRecord[];
  }>
> {
  return request(`${ServiceProxy.DefaultPrefix}/inventory-history`, {
    method: 'GET',
    params,
  });
}

// 删除
export async function deleteInventoryHistory(
  id: number,
): Promise<RequestResult<void>> {
  return request(`${ServiceProxy.DefaultPrefix}/inventory-history/${id}`, {
    method: 'DELETE',
  });
}

// 更新
export async function updateInventoryHistory(
  id: number,
  data: Pick<
    InventoryHistoryRecord,
    'description' | 'price' | 'type' | 'marketPrice' | 'nub'
  >,
): Promise<RequestResult<void>> {
  return request(`${ServiceProxy.DefaultPrefix}/inventory-history//${id}`, {
    method: 'PUT',
    data,
  });
}

// 创建
export async function addInventoryHistory(
  data: Pick<
    InventoryHistoryRecord,
    'description' | 'price' | 'type' | 'marketPrice' | 'nub' | 'brandId'
  >,
): Promise<RequestResult<void>> {
  return request(`${ServiceProxy.DefaultPrefix}/inventory-history`, {
    method: 'POST',
    data,
  });
}
